package lovo.practice_7_14;

import lovo.Util.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MunePanel extends JPanel implements ActionListener {
    private J189_7_14 frame;
    private Icon ImageGet = Util.getimagesIcon("/Images/buttonGet.jpg");
    private Icon ImageSave = Util.getimagesIcon("/Images/buttonSave.jpg");
    private Icon ImageFind = Util.getimagesIcon("/Images/buttonFind.jpg");
    private Icon imgback = Util.getimagesIcon("/Images/buttonOff.jpg");
    private JButton jButtonTrans = new JButton("转账");
    private JButton jButtonSave;
    private JButton jButtonGet;
    private JButton jButtonFind;
    private JButton jButtonBack;
    private JButton jButtonSetPwd;

    public MunePanel(J189_7_14 frame) {
        this.frame = frame;
        this.setLayout(null);
        this.setOpaque(false);
        jButtonSave = new JButton(ImageSave);
        jButtonSave.setBounds(200, 200, 140, 50);
        this.add(jButtonSave);

        jButtonGet = new JButton(ImageGet);
        jButtonGet.setBounds(200, 400, 140, 50);
        this.add(jButtonGet);

        jButtonFind = new JButton(ImageFind);


        jButtonFind.setBounds(600, 200, 140, 50);
        this.add(jButtonFind);


        jButtonBack = new JButton(imgback);
        jButtonBack.setBounds(600, 400, 140, 50);
        this.add(jButtonBack);

        jButtonTrans.setBounds(200, 600, 140, 50);
        this.add(jButtonTrans);
        jButtonSetPwd = new JButton("改密");
        jButtonSetPwd.setBounds(600, 600, 140, 50);
        this.add(jButtonSetPwd);


        jButtonBack.addActionListener(this);
        jButtonTrans.addActionListener(this);
        jButtonSave.addActionListener(this);
        jButtonGet.addActionListener(this);
        jButtonFind.addActionListener(this);
        jButtonSetPwd.addActionListener(this);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jButtonSave) {
            frame.switchPanel("save");
        } else if (e.getSource() == jButtonGet) {
            frame.switchPanel("get");
        } else if (e.getSource() == jButtonFind) {
            frame.setMoney();
            frame.switchPanel("find");

        } else if (e.getSource() == jButtonBack) {
            frame.getScanPanel().setFalsetime(3);
            frame.switchPanel("scan");
        } else if (e.getSource() == jButtonTrans) {
            frame.switchPanel("trans");
        } else if (e.getSource() == jButtonSetPwd) {
            frame.switchPanel("setPwd");
        }
    }
}

